﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BKH.BLL
{
    class BenhNhan_LanKhamBUO:IBUO<tbl_BenhNhan_LanKham>
    {
        HospitalDBDataContext context = new HospitalDBDataContext();
        public bool Insert(tbl_BenhNhan_LanKham obj)
        {
            try
            {
                context.tbl_BenhNhan_LanKhams.InsertOnSubmit(obj);
                context.SubmitChanges();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public bool Delete(int id)
        {
            throw new NotImplementedException();
        }

        public bool Delete(tbl_BenhNhan_LanKham obj)
        {
            throw new NotImplementedException();
        }

        public List<tbl_BenhNhan_LanKham> GetAll()
        {
            throw new NotImplementedException();
        }

        public tbl_BenhNhan_LanKham GetSingle(int id)
        {
            return context.tbl_BenhNhan_LanKhams.Where(n => n.BenhNhanID == id).ToList().FirstOrDefault();
            
        }

        public bool Update(int id, tbl_BenhNhan_LanKham obj)
        {
            throw new NotImplementedException();
        }
        public tbl_BenhNhan_LanKham GetLanKhamCuoi(int idbn)

        {
            return context.tbl_BenhNhan_LanKhams.Where(n => n.BenhNhanID == idbn).OrderByDescending(k => k.LanKhamID).ToList<tbl_BenhNhan_LanKham>().FirstOrDefault();
        }
    }
}
